Page({
  data: {

  name:'',
  staffid:'',
  lst:{


  },


  },
  onLoad() {

var that=this;

  dd.getStorage({
  key: 'staffid',
  success: function(res) 
  { 
    //console.log(res.data);
  that.setData({

   staffid:res.data

  });
  dd.httpRequest({

        
          //提交工号和授权码，如果授权码和工号对上了就返回姓名，然后保存工号到缓存
          //url: 'https://oapi.dingtalk.com/user/getuserinfo?access_token=' + access_token + '&code=' + code,
        
          url:'http://ding.tida-lighting.com/api/Leave/GetCarSendList?staffid='+res.data,
          success: function (res) {
         
         // console.log(that.data.staffid);
          that.setData({
             lst:res.data,
            
          });

          console.log(res.data);
         },
        fail: (err) => {
           //dd.alert({content: JSON.stringify(err)})
           console.log(err);
        }

     });//发起结束
  },
  fail: function(res){
    dd.alert({content: res.errorMessage});
  }
});


    


  },
  begin:function(e){
   
      dd.chooseImage({ //请求图片

      count: 1,  //上传图片张数限制 

      success: (res) => {

      console.log("返回的文件信息为:");

      console.log(res);
      console.log(e);
      console.log(res.filePaths[0]);

          dd.uploadFile({
            url:'http://ding.tida-lighting.com/api/leave/imgbeginsendcar',
            fileType: 'image',
            fileName: 'img',
            filePath:res.filePaths[0], 
            formData: { 
            type:'begin',
            id:e.currentTarget.dataset.value,

            
            
            },
            

            success: function (re) {
               console.log(re);
            dd.showToast({
            content: re.data.msg
          });



        }


});}});},


end:function(e){
   
      dd.chooseImage({ //请求图片

      count: 1,  //上传图片张数限制 

      success: (res) => {

     // console.log("返回的文件信息为:");

    //  console.log(res);
      console.log(e);
      console.log(res.filePaths[0]);

          dd.uploadFile({
            url:'http://ding.tida-lighting.com/api/leave/imgbeginsendcar',
            fileType: 'image',
            fileName: 'img',
            filePath:res.filePaths[0], 
            formData: { 
            type:'end',
            id:e.currentTarget.dataset.value,

            
            
            },
            

            success: function (re) {
            console.log(re);
            dd.showToast({
            content: re.data.msg
          });



        }


});}});},

}

);
